package com.costeaalex.blueserver.interfaces.setup;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.costeaalex.blueserver.setup.SetupServerApp;

public class ScreenSetupStartupRegister extends JPanel
	{

	private static final long	serialVersionUID	= -7762105840751509106L;
	
	
	private JButton yes;
	private JButton no;
	private SetupServerApp sSAL;
	private Listener l;
	private boolean actionPerformed=false;
	
	public ScreenSetupStartupRegister(SetupServerApp sSA)
		{
		super();
		l=new Listener();
		sSAL=sSA;
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		JLabel jTAS=new JLabel(" Setup ");
		this.add(jTAS);
		
		this.add(new JLabel("     "));
		this.add(new JLabel(" Do you want to register this service at startup?"));
		this.add(new JLabel("     "));
		this.add(new JLabel(" If you select yes then this application will start"));
		this.add(new JLabel(" automatically when windows starts!"));
		this.add(new JLabel("     "));
		
		yes=new JButton("Yes");
		yes.addActionListener(l);
		no=new JButton("No");
		no.addActionListener(l);
		this.add(yes);
		this.add(no);
		}

	public class Listener implements ActionListener
		{
		public void actionPerformed(ActionEvent a)
			{
			if(!actionPerformed)
				{
				actionPerformed=true;
				if(a.getSource()==yes)
					{
					sSAL.registerStartup=1;
					}
				
				if(a.getSource()==no)
					{
					sSAL.registerStartup=2;
					}
				}
			}
		}
	
	}
